package com.wyl;

import com.wyl.R;

import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.net.Uri;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class WhereYouLiveActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        final EditText addressfield = (EditText) findViewById(R.id.addresEditText);
        final Button launchBtn = (Button) findViewById(R.id.launchButton);
        launchBtn.setOnClickListener(new Button.OnClickListener()
        {
        	public void onClick(View v)
        	{
        		try
        		{
        		 String addres = addressfield.getText().toString();
        		 addres = addres.replace(' ', '+');
        		 
        		 Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("geo:0,0?q=" + addres));
        		 startActivity(myIntent);
        		}
        		catch(Exception ex)
        		{
        			TextView errorText = (TextView) findViewById(R.id.errorTextView);
        			errorText.setText(ex.getMessage());
        		}
        	}
        });
    }
}